#include<stdio.h>
int main()
{
	int m,n,i,x;
	scanf("%d,%d",&m,&n);
	if(m>n)
	{ 
	  {
	  	{
	   if(m%n==0) printf("maxgongyue %d\n",n);
	   else
		   for(i=n;m%n==0;i--) printf("maxgongyue %d\n",i);
	}
	     {
		 x=m;
	     if(x%m==0&&x%n==0) printf("mingongbei %d\n",x); 
	     else
			for(x=m;x%m==0&&x%n==0;x++) printf("mingongbei %d\n",x);
	return 0;
		}  
    }
    else
    {
    	{
    	if(n%m==0) printf("maxgongyue %d\n",n);
    	else
    	    for(i=m;i>=1;i--);
    	if(n%m==0) 
		   printf("maxgongyue %d\n",n);
		x=n;
		if(x%m==0&&x%n==0) printf("mingongbei %d\n",x);
		else
		  for(x=n;x>0;x++)
		  if(x%m==0&&x%n==0)
		  printf("mingongbei %d\n",x);
		  return 0;
       }
	}
}


